home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / hplip / ui4 / systrayframe.py < prev    next >
Encoding:
Python Source  |  2009-04-14  |  6.0 KB  |  159 lines

  1. # -*- coding: utf-8 -*-
  2. #
  3. # (c) Copyright 2001-2008 Hewlett-Packard Development Company, L.P.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  18. #
  19. # Author: Don Welch
  20. #
  21.  
  22. # Local
  23. from base.g import *
  24. from base.codes import *
  25. from ui_utils import *
  26.  
  27. # Qt
  28. from PyQt4.QtCore import *
  29. from PyQt4.QtGui import *
  30.  
  31.  
  32. class SystrayFrame(QFrame):
  33.     def __init__(self, parent):
  34.         QFrame.__init__(self, parent)
  35. #        self.systray_visible = 0
  36. #        self.polling = polling
  37. #        self.polling_interval = polling_interval
  38. #        self.device_list = device_list
  39.         #self.initUi()
  40.         
  41.  
  42.     def initUi(self, systray_visible, polling, polling_interval, device_list):
  43.         self.systray_visible = systray_visible
  44.         self.polling = polling
  45.         self.polling_interval = polling_interval
  46.         self.device_list = device_list
  47.         
  48.         self.GridLayout = QGridLayout(self)
  49.         self.GridLayout.setObjectName("GridLayout")
  50.  
  51.         self.GroupBox2 = QGroupBox(self)
  52.         self.GroupBox2.setObjectName("GroupBox2")
  53.  
  54.         self.GridLayout2 = QGridLayout(self.GroupBox2)
  55.         self.GridLayout2.setObjectName("GridLayout2")
  56.  
  57.         self.ShowAlwaysRadioButton = QRadioButton(self.GroupBox2)
  58.         self.ShowAlwaysRadioButton.setObjectName("ShowAlwaysRadioButton")
  59.         self.GridLayout2.addWidget(self.ShowAlwaysRadioButton,0,0,1,1)
  60.  
  61.         self.HideWhenInactiveRadioButton = QRadioButton(self.GroupBox2)
  62.         self.HideWhenInactiveRadioButton.setObjectName("HideWhenInactiveRadioButton")
  63.         self.GridLayout2.addWidget(self.HideWhenInactiveRadioButton,1,0,1,1)
  64.  
  65.         self.HideAlwaysRadioButton = QRadioButton(self.GroupBox2)
  66.         self.HideAlwaysRadioButton.setObjectName("HideAlwaysRadioButton")
  67.         self.GridLayout2.addWidget(self.HideAlwaysRadioButton,2,0,1,1)
  68.         
  69.         self.GridLayout.addWidget(self.GroupBox2,0,0,1,1)
  70.  
  71.         self.GroupBox = QGroupBox(self)
  72.         self.GroupBox.setCheckable(True)
  73.         self.GroupBox.setObjectName("GroupBox")
  74.  
  75.         self.GridLayout3 = QGridLayout(self.GroupBox)
  76.         self.GridLayout3.setObjectName("GridLayout3")
  77.  
  78.         self.label = QLabel(self.GroupBox)
  79.         self.label.setObjectName("label")
  80.         self.GridLayout3.addWidget(self.label,0,0,1,1)
  81.  
  82.         self.DevicesListWidget = QListWidget(self.GroupBox)
  83.         self.DevicesListWidget.setObjectName("DevicesListWidget")
  84.         self.GridLayout3.addWidget(self.DevicesListWidget,1,0,1,1)
  85.         
  86.         self.GridLayout.addWidget(self.GroupBox,1,0,1,1)
  87.         
  88.         self.GroupBox2.setTitle(self.__tr("System tray icon visibility"))
  89.         self.ShowAlwaysRadioButton.setText(self.__tr("Always show"))
  90.         self.HideWhenInactiveRadioButton.setText(self.__tr("Hide when inactive"))
  91.         self.HideAlwaysRadioButton.setText(self.__tr("Always hide"))
  92.         self.GroupBox.setTitle(self.__tr("Monitor button presses on devices"))
  93.         self.label.setText(self.__tr("Devices to Monitor:"))
  94.         
  95.         self.connect(self.ShowAlwaysRadioButton, SIGNAL("clicked(bool)"), self.ShowAlwaysRadioButton_clicked)
  96.         self.connect(self.HideWhenInactiveRadioButton, SIGNAL("clicked(bool)"), self.HideWhenInactiveRadioButton_clicked)
  97.         self.connect(self.HideAlwaysRadioButton, SIGNAL("clicked(bool)"), self.HideAlwaysRadioButton_clicked)
  98.         
  99.         self.GroupBox.setEnabled(False) # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  100.  
  101.  
  102.     def updateUi(self):
  103.         self.updateVisibility()
  104.         self.updateDeviceList()
  105.         
  106.         
  107.     def updateVisibility(self):
  108.         if self.systray_visible == SYSTRAY_VISIBLE_SHOW_ALWAYS:
  109.             self.ShowAlwaysRadioButton.setChecked(True)
  110.             
  111.         elif self.systray_visible == SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE:
  112.             self.HideWhenInactiveRadioButton.setChecked(True)
  113.             
  114.         else: # SYSTRAY_VISIBLE_HIDE_ALWAYS
  115.             self.HideAlwaysRadioButton.setChecked(True)
  116.             
  117.     
  118.     def ShowAlwaysRadioButton_clicked(self, b):
  119.         if b: self.systray_visible = SYSTRAY_VISIBLE_SHOW_ALWAYS
  120.         
  121.         
  122.     def HideWhenInactiveRadioButton_clicked(self, b):
  123.         if b: self.systray_visible = SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE
  124.         
  125.         
  126.     def HideAlwaysRadioButton_clicked(self, b):
  127.         if b: self.systray_visible = SYSTRAY_VISIBLE_HIDE_ALWAYS
  128.     
  129.     
  130.     def updateDeviceList(self):    
  131.         pass
  132.         
  133.         
  134. #    def saveSettings(self):
  135. ##        print self.ShowAlwaysRadioButton.isChecked()
  136. ##        print self.HideWhenInactiveRadioButton.isChecked()
  137. ##        print self.HideAlwaysRadioButton.isChecked()
  138. #        
  139. #        if self.ShowAlwaysRadioButton.isChecked():
  140. #            print "show always"
  141. #            self.user_settings.systray_visible = SYSTRAY_VISIBLE_SHOW_ALWAYS
  142. #            
  143. #        elif self.HideWhenInactiveRadioButton.isChecked():
  144. #            print "hide when inactive"
  145. #            self.user_settings.systray_visible = SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE
  146. #            
  147. #        else: # HideAlwaysRadioButton.isChecked()
  148. #            print "hide always"
  149. #            self.user_settings.systray_visible = SYSTRAY_VISIBLE_HIDE_ALWAYS
  150. #            
  151. #        self.systray_visible = self.user_settings.systray_visible
  152. #        self.user_settings.save()
  153.             
  154.             
  155.     def __tr(self, s, c=None):
  156.         #return qApp.translate("SystrayFrame", s, c)
  157.         return QApplication.translate("SystrayFrame", s, c, QApplication.UnicodeUTF8)
  158.         
  159.